/*
 * Copyright (c) 2010, Oracle. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 *
 * * Neither the name of Oracle nor the names of its contributors
 *   may be used to endorse or promote products derived from this software without
 *   specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

package Flexible_OpenSource_EBike_firmware_configuration_tool;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.showMessageDialog;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.io.PrintWriter;
import java.io.BufferedWriter; 
import java.io.FileWriter;
import java.io.InputStreamReader;

public class Configuration_tool extends javax.swing.JFrame {
    
    /**
     * Creates new form ContactEditor
     */
    public Configuration_tool() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        LABEL_throttle_type = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        throttle_type = new javax.swing.JComboBox<>();
        pas_number_of_magnets = new javax.swing.JTextField();
        LABEL_pas_number_of_magnets = new javax.swing.JLabel();
        torque_sensor_control_algorithm_output = new javax.swing.JComboBox<>();
        LABEL_torque_sensor_control_algorithm_output = new javax.swing.JLabel();
        throttle_control_algorithm_output = new javax.swing.JComboBox<>();
        LABEL_throttle_control_algorithm_output = new javax.swing.JLabel();
        LABEL_pedal_max_cadence_in_rpm = new javax.swing.JLabel();
        pedal_max_cadence_in_rpm = new javax.swing.JTextField();
        LABEL_pas_rotation_direction = new javax.swing.JLabel();
        pas_rotation_direction = new javax.swing.JComboBox<>();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        LABEL_LCD_assist_level_0 = new javax.swing.JLabel();
        LCD_assist_level_0 = new javax.swing.JTextField();
        LABEL_LCD_assist_level_1 = new javax.swing.JLabel();
        LCD_assist_level_1 = new javax.swing.JTextField();
        LABEL_LCD_assist_level_2 = new javax.swing.JLabel();
        LCD_assist_level_2 = new javax.swing.JTextField();
        LABEL_LCD_assist_level_3 = new javax.swing.JLabel();
        LCD_assist_level_3 = new javax.swing.JTextField();
        LABEL_LCD_assist_level_4 = new javax.swing.JLabel();
        LCD_assist_level_4 = new javax.swing.JTextField();
        LABEL_LCD_assist_level_5 = new javax.swing.JLabel();
        LCD_assist_level_5 = new javax.swing.JTextField();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        LABEL_lion_cells_number = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        LABEL_motor_rotor_offset_angle = new javax.swing.JLabel();
        motor_rotor_offset_angle = new javax.swing.JTextField();
        LABEL_foc_read_id_current_angle_adjust = new javax.swing.JLabel();
        foc_read_id_current_angle_adjust = new javax.swing.JTextField();
        LABEL_motor_start_interpolation_60_degrees = new javax.swing.JLabel();
        motor_start_interpolation_60_degrees = new javax.swing.JTextField();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel6 = new javax.swing.JLabel();
        LABEL_motor_max_current = new javax.swing.JLabel();
        motor_max_current = new javax.swing.JTextField();
        LABEL_motor_max_regen_current = new javax.swing.JLabel();
        motor_max_regen_current = new javax.swing.JTextField();
        LABEL_pwm_duty_cycle_ramp_up_step = new javax.swing.JLabel();
        pwm_duty_cycle_ramp_up_step = new javax.swing.JTextField();
        LABEL_pwm_duty_cycle_ramp_down_step = new javax.swing.JLabel();
        pwm_duty_cycle_ramp_down_step = new javax.swing.JTextField();
        ButtonWriteConfiguration = new javax.swing.JButton();
        jSeparator7 = new javax.swing.JSeparator();
        ButtonWriteOptionBytes = new javax.swing.JButton();
        LABEL_throttle_type_HELP = new javax.swing.JLabel();
        LABEL_throttle_control_algorithm_output_HELP = new javax.swing.JLabel();
        LABEL_torque_sensor_control_algorithm_output_HELP = new javax.swing.JLabel();
        LABEL_pas_number_of_magnets_HELP = new javax.swing.JLabel();
        LABEL_pas_rotation_direction_HELP = new javax.swing.JLabel();
        LABEL_pedal_max_cadence_in_rpm_HELP = new javax.swing.JLabel();
        LABEL_LCD_assist_level_0_HELP = new javax.swing.JLabel();
        LABEL_motor_rotor_offset_angle_HELP = new javax.swing.JLabel();
        LABEL_foc_read_id_current_angle_adjust_HELP = new javax.swing.JLabel();
        LABEL_motor_start_interpolation_60_degrees_HELP = new javax.swing.JLabel();
        LABEL_pwm_duty_cycle_ramp_up_step_HELP = new javax.swing.JLabel();
        LABEL_motor_max_current_HELP = new javax.swing.JLabel();
        LABEL_motor_max_regen_current_HELP = new javax.swing.JLabel();
        LABEL_pwm_duty_cycle_ramp_down_step_HELP = new javax.swing.JLabel();
        ButtonWriteConfiguration_HELP = new javax.swing.JLabel();
        ButtonWriteOptionBytes_HELP = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        lion_cells_number = new javax.swing.JTextField();
        LABEL_lion_cells_number_HELP = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Configuration tool");
        setBounds(new java.awt.Rectangle(0, 0, 500, 700));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(500, 500));
        setSize(new java.awt.Dimension(500, 700));

        jScrollPane1.setHorizontalScrollBar(null);
        jScrollPane1.setMinimumSize(new java.awt.Dimension(500, 500));
        jScrollPane1.setPreferredSize(new java.awt.Dimension(500, 700));

        jPanel1.setMinimumSize(new java.awt.Dimension(500, 2250));
        jPanel1.setName(""); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(500, 2250));
        jPanel1.setRequestFocusEnabled(false);

        LABEL_throttle_type.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_throttle_type.setText("Throttle type");

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel1.setText("Throttle type");

        throttle_type.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        throttle_type.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "throttle and/or PAS", "torque sensor" }));
        throttle_type.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                throttle_typeActionPerformed(evt);
            }
        });

        pas_number_of_magnets.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        pas_number_of_magnets.setText("5");
        pas_number_of_magnets.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pas_number_of_magnetsActionPerformed(evt);
            }
        });

        LABEL_pas_number_of_magnets.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pas_number_of_magnets.setText("PAS number of magnets");

        torque_sensor_control_algorithm_output.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        torque_sensor_control_algorithm_output.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "direct torque value", "human power" }));
        torque_sensor_control_algorithm_output.setVisible(false);
        torque_sensor_control_algorithm_output.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                torque_sensor_control_algorithm_outputActionPerformed(evt);
            }
        });

        LABEL_torque_sensor_control_algorithm_output.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_torque_sensor_control_algorithm_output.setText("Torque sensor control algorithm output");
        LABEL_torque_sensor_control_algorithm_output.setVisible(false);

        throttle_control_algorithm_output.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        throttle_control_algorithm_output.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "direct PWM duty-cycle", "motor current and/or speed" }));
        throttle_control_algorithm_output.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                throttle_control_algorithm_outputActionPerformed(evt);
            }
        });

        LABEL_throttle_control_algorithm_output.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_throttle_control_algorithm_output.setText("Throttle control algorithm output");

        LABEL_pedal_max_cadence_in_rpm.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pedal_max_cadence_in_rpm.setText("Pedal max cadence in RPM");

        pedal_max_cadence_in_rpm.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        pedal_max_cadence_in_rpm.setText("80");
        pedal_max_cadence_in_rpm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pedal_max_cadence_in_rpmActionPerformed(evt);
            }
        });

        LABEL_pas_rotation_direction.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pas_rotation_direction.setText("PAS rotation direction");

        pas_rotation_direction.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        pas_rotation_direction.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "left", "right" }));
        pas_rotation_direction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pas_rotation_directionActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel2.setText("LCD");

        LABEL_LCD_assist_level_0.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_0.setText("Assist level 0");

        LCD_assist_level_0.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LCD_assist_level_0.setText("0.0");
        LCD_assist_level_0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LCD_assist_level_0ActionPerformed(evt);
            }
        });

        LABEL_LCD_assist_level_1.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_1.setText("Assist level 1");

        LCD_assist_level_1.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LCD_assist_level_1.setText("0.2");
        LCD_assist_level_1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LCD_assist_level_1ActionPerformed(evt);
            }
        });

        LABEL_LCD_assist_level_2.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_2.setText("Assist level 2");

        LCD_assist_level_2.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LCD_assist_level_2.setText("0.4");
        LCD_assist_level_2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LCD_assist_level_2ActionPerformed(evt);
            }
        });

        LABEL_LCD_assist_level_3.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_3.setText("Assist level 3");

        LCD_assist_level_3.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LCD_assist_level_3.setText("0.6");
        LCD_assist_level_3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LCD_assist_level_3ActionPerformed(evt);
            }
        });

        LABEL_LCD_assist_level_4.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_4.setText("Assist level 4");

        LCD_assist_level_4.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LCD_assist_level_4.setText("0.8");
        LCD_assist_level_4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LCD_assist_level_4ActionPerformed(evt);
            }
        });

        LABEL_LCD_assist_level_5.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_5.setText("Assist level 5");

        LCD_assist_level_5.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LCD_assist_level_5.setText("1.0");
        LCD_assist_level_5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LCD_assist_level_5ActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel3.setText("Battery");

        LABEL_lion_cells_number.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_lion_cells_number.setText("Li-ion cells number");

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel4.setText("Motor");

        LABEL_motor_rotor_offset_angle.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_rotor_offset_angle.setText("Motor rotor offset angle");

        motor_rotor_offset_angle.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        motor_rotor_offset_angle.setText("202");
        motor_rotor_offset_angle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                motor_rotor_offset_angleActionPerformed(evt);
            }
        });

        LABEL_foc_read_id_current_angle_adjust.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_foc_read_id_current_angle_adjust.setText("FOC read ID current angle adjust");

        foc_read_id_current_angle_adjust.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        foc_read_id_current_angle_adjust.setText("137");
        foc_read_id_current_angle_adjust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                foc_read_id_current_angle_adjustActionPerformed(evt);
            }
        });

        LABEL_motor_start_interpolation_60_degrees.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_start_interpolation_60_degrees.setText("Motor start interpolation 60 degrees");

        motor_start_interpolation_60_degrees.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        motor_start_interpolation_60_degrees.setText("40");
        motor_start_interpolation_60_degrees.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                motor_start_interpolation_60_degreesActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Ubuntu", 1, 24)); // NOI18N
        jLabel6.setText("Motor controller");

        LABEL_motor_max_current.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_max_current.setText("Motor max current (amps)");

        motor_max_current.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        motor_max_current.setText("15");
        motor_max_current.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                motor_max_currentActionPerformed(evt);
            }
        });

        LABEL_motor_max_regen_current.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_max_regen_current.setText("Motor max regen/ebrake current");

        motor_max_regen_current.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        motor_max_regen_current.setText("7");
        motor_max_regen_current.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                motor_max_regen_currentActionPerformed(evt);
            }
        });

        LABEL_pwm_duty_cycle_ramp_up_step.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pwm_duty_cycle_ramp_up_step.setText("PWM duty-cycle ramp up step");

        pwm_duty_cycle_ramp_up_step.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        pwm_duty_cycle_ramp_up_step.setText("25");
        pwm_duty_cycle_ramp_up_step.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pwm_duty_cycle_ramp_up_stepActionPerformed(evt);
            }
        });

        LABEL_pwm_duty_cycle_ramp_down_step.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pwm_duty_cycle_ramp_down_step.setText("PWM duty-cycle ramp down step");

        pwm_duty_cycle_ramp_down_step.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        pwm_duty_cycle_ramp_down_step.setText("25");
        pwm_duty_cycle_ramp_down_step.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pwm_duty_cycle_ramp_down_stepActionPerformed(evt);
            }
        });

        ButtonWriteConfiguration.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
        ButtonWriteConfiguration.setText("Write configuration");
        ButtonWriteConfiguration.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonWriteConfigurationActionPerformed(evt);
            }
        });

        ButtonWriteOptionBytes.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
        ButtonWriteOptionBytes.setText("Write option bytes");
        ButtonWriteOptionBytes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonWriteOptionBytesActionPerformed(evt);
            }
        });

        LABEL_throttle_type_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_throttle_type_HELP.setText("<html><u>help</u></html>");
        LABEL_throttle_type_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_throttle_type_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_throttle_type_HELPMouseClicked(evt);
            }
        });

        LABEL_throttle_control_algorithm_output_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_throttle_control_algorithm_output_HELP.setText("<html><u>help</u></html>");
        LABEL_throttle_control_algorithm_output_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_throttle_control_algorithm_output_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_throttle_control_algorithm_output_HELPMouseClicked(evt);
            }
        });

        LABEL_torque_sensor_control_algorithm_output_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_torque_sensor_control_algorithm_output_HELP.setText("<html><u>help</u></html>");
        LABEL_torque_sensor_control_algorithm_output_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_torque_sensor_control_algorithm_output_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_torque_sensor_control_algorithm_output_HELPMouseClicked(evt);
            }
        });

        LABEL_pas_number_of_magnets_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pas_number_of_magnets_HELP.setText("<html><u>help</u></html>");
        LABEL_pas_number_of_magnets_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_pas_number_of_magnets_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_pas_number_of_magnets_HELPMouseClicked(evt);
            }
        });

        LABEL_pas_rotation_direction_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pas_rotation_direction_HELP.setText("<html><u>help</u></html>");
        LABEL_pas_rotation_direction_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_pas_rotation_direction_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_pas_rotation_direction_HELPMouseClicked(evt);
            }
        });

        LABEL_pedal_max_cadence_in_rpm_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pedal_max_cadence_in_rpm_HELP.setText("<html><u>help</u></html>");
        LABEL_pedal_max_cadence_in_rpm_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_pedal_max_cadence_in_rpm_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_pedal_max_cadence_in_rpm_HELPMouseClicked(evt);
            }
        });

        LABEL_LCD_assist_level_0_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_LCD_assist_level_0_HELP.setText("<html><u>help</u></html>");
        LABEL_LCD_assist_level_0_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_LCD_assist_level_0_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_LCD_assist_level_0_HELPMouseClicked(evt);
            }
        });

        LABEL_motor_rotor_offset_angle_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_rotor_offset_angle_HELP.setText("<html><u>help</u></html>");
        LABEL_motor_rotor_offset_angle_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_motor_rotor_offset_angle_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_motor_rotor_offset_angle_HELPMouseClicked(evt);
            }
        });

        LABEL_foc_read_id_current_angle_adjust_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_foc_read_id_current_angle_adjust_HELP.setText("<html><u>help</u></html>");
        LABEL_foc_read_id_current_angle_adjust_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_foc_read_id_current_angle_adjust_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_foc_read_id_current_angle_adjust_HELPMouseClicked(evt);
            }
        });

        LABEL_motor_start_interpolation_60_degrees_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_start_interpolation_60_degrees_HELP.setText("<html><u>help</u></html>");
        LABEL_motor_start_interpolation_60_degrees_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_motor_start_interpolation_60_degrees_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_motor_start_interpolation_60_degrees_HELPMouseClicked(evt);
            }
        });

        LABEL_pwm_duty_cycle_ramp_up_step_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pwm_duty_cycle_ramp_up_step_HELP.setText("<html><u>help</u></html>");
        LABEL_pwm_duty_cycle_ramp_up_step_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_pwm_duty_cycle_ramp_up_step_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_pwm_duty_cycle_ramp_up_step_HELPMouseClicked(evt);
            }
        });

        LABEL_motor_max_current_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_max_current_HELP.setText("<html><u>help</u></html>");
        LABEL_motor_max_current_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_motor_max_current_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_motor_max_current_HELPMouseClicked(evt);
            }
        });

        LABEL_motor_max_regen_current_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_motor_max_regen_current_HELP.setText("<html><u>help</u></html>");
        LABEL_motor_max_regen_current_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_motor_max_regen_current_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_motor_max_regen_current_HELPMouseClicked(evt);
            }
        });

        LABEL_pwm_duty_cycle_ramp_down_step_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_pwm_duty_cycle_ramp_down_step_HELP.setText("<html><u>help</u></html>");
        LABEL_pwm_duty_cycle_ramp_down_step_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_pwm_duty_cycle_ramp_down_step_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_pwm_duty_cycle_ramp_down_step_HELPMouseClicked(evt);
            }
        });

        ButtonWriteConfiguration_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        ButtonWriteConfiguration_HELP.setText("<html><u>help</u></html>");
        ButtonWriteConfiguration_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        ButtonWriteConfiguration_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonWriteConfiguration_HELPMouseClicked(evt);
            }
        });

        ButtonWriteOptionBytes_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        ButtonWriteOptionBytes_HELP.setText("<html><u>help</u></html>");
        ButtonWriteOptionBytes_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        ButtonWriteOptionBytes_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ButtonWriteOptionBytes_HELPMouseClicked(evt);
            }
        });

        jTextPane1.setEditable(false);
        jTextPane1.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jTextPane1.setText("The default options work well for the following hardware combination:\n- throttle type: BMSBattery bottom bracket torque sensor\n- LCD: BMSBattery LCD5\n- battery: Li-ion 24V (7S)\n- motor: BMSBattery Q85 328 RPM 24V (geared)\n- motor controller: BMSBattery S06S\n\nIf you are not sure about some option, keep the default values as they will probably be a ok.");
        jScrollPane2.setViewportView(jTextPane1);

        lion_cells_number.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        lion_cells_number.setText("7");
        lion_cells_number.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lion_cells_numberActionPerformed(evt);
            }
        });

        LABEL_lion_cells_number_HELP.setFont(new java.awt.Font("Ubuntu", 0, 18)); // NOI18N
        LABEL_lion_cells_number_HELP.setText("<html><u>help</u></html>");
        LABEL_lion_cells_number_HELP.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
        LABEL_lion_cells_number_HELP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LABEL_lion_cells_number_HELPMouseClicked(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(25, 25, 25)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 437, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jSeparator3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 437, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jSeparator4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 437, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(torque_sensor_control_algorithm_output, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 437, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(throttle_control_algorithm_output, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 437, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(throttle_type, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 437, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(jPanel1Layout.createSequentialGroup()
                                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_motor_max_regen_current)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_lion_cells_number, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_LCD_assist_level_5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_LCD_assist_level_4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_LCD_assist_level_3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_LCD_assist_level_2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_LCD_assist_level_1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_throttle_type, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_throttle_control_algorithm_output, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, pwm_duty_cycle_ramp_down_step, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, pwm_duty_cycle_ramp_up_step, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, motor_max_current, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel6)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, motor_start_interpolation_60_degrees, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, foc_read_id_current_angle_adjust, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, motor_rotor_offset_angle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel4)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, pas_number_of_magnets, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, pedal_max_cadence_in_rpm, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LCD_assist_level_0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LCD_assist_level_1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LCD_assist_level_4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LCD_assist_level_5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LCD_assist_level_2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LCD_assist_level_3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_torque_sensor_control_algorithm_output)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_motor_max_current, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 266, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()
                                            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_foc_read_id_current_angle_adjust, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_pwm_duty_cycle_ramp_down_step, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_pwm_duty_cycle_ramp_up_step, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_motor_start_interpolation_60_degrees, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_motor_rotor_offset_angle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_pedal_max_cadence_in_rpm, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_pas_number_of_magnets, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_pas_rotation_direction, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(org.jdesktop.layout.GroupLayout.LEADING, LABEL_LCD_assist_level_0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                            .add(41, 41, 41)))
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 67, Short.MAX_VALUE)
                                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_throttle_type_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_throttle_control_algorithm_output_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_torque_sensor_control_algorithm_output_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_pas_number_of_magnets_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_pedal_max_cadence_in_rpm_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_pas_rotation_direction_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_LCD_assist_level_0_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_motor_rotor_offset_angle_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_foc_read_id_current_angle_adjust_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_motor_start_interpolation_60_degrees_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_motor_max_current_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_motor_max_regen_current_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_pwm_duty_cycle_ramp_up_step_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_pwm_duty_cycle_ramp_down_step_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, LABEL_lion_cells_number_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                                .add(pas_rotation_direction, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(jSeparator7)
                                .add(jSeparator6)
                                .add(motor_max_regen_current, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel1)
                                .add(lion_cells_number, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(ButtonWriteConfiguration_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(82, 82, 82)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(ButtonWriteConfiguration, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel1Layout.createSequentialGroup()
                                .add(ButtonWriteOptionBytes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(ButtonWriteOptionBytes_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                .add(25, 25, 25))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(20, 20, 20)
                .add(jLabel1)
                .add(20, 20, 20)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_throttle_type)
                    .add(LABEL_throttle_type_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(throttle_type, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_throttle_control_algorithm_output)
                    .add(LABEL_throttle_control_algorithm_output_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(throttle_control_algorithm_output, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_torque_sensor_control_algorithm_output)
                    .add(LABEL_torque_sensor_control_algorithm_output_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(torque_sensor_control_algorithm_output, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_pas_number_of_magnets)
                    .add(LABEL_pas_number_of_magnets_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(pas_number_of_magnets, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_pedal_max_cadence_in_rpm)
                    .add(LABEL_pedal_max_cadence_in_rpm_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(pedal_max_cadence_in_rpm, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_pas_rotation_direction)
                    .add(LABEL_pas_rotation_direction_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pas_rotation_direction, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jSeparator2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(20, 20, 20)
                .add(jLabel2)
                .add(20, 20, 20)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_LCD_assist_level_0)
                    .add(LABEL_LCD_assist_level_0_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(LCD_assist_level_0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(LABEL_LCD_assist_level_1)
                .add(6, 6, 6)
                .add(LCD_assist_level_1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(LABEL_LCD_assist_level_2)
                .add(6, 6, 6)
                .add(LCD_assist_level_2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(LABEL_LCD_assist_level_3)
                .add(6, 6, 6)
                .add(LCD_assist_level_3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(LABEL_LCD_assist_level_4)
                .add(6, 6, 6)
                .add(LCD_assist_level_4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(LABEL_LCD_assist_level_5)
                .add(6, 6, 6)
                .add(LCD_assist_level_5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jSeparator3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jLabel3)
                .add(20, 20, 20)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_lion_cells_number)
                    .add(LABEL_lion_cells_number_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(lion_cells_number, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jSeparator4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(20, 20, 20)
                .add(jLabel4)
                .add(20, 20, 20)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_motor_rotor_offset_angle)
                    .add(LABEL_motor_rotor_offset_angle_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(motor_rotor_offset_angle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_foc_read_id_current_angle_adjust)
                    .add(LABEL_foc_read_id_current_angle_adjust_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(foc_read_id_current_angle_adjust, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_motor_start_interpolation_60_degrees)
                    .add(LABEL_motor_start_interpolation_60_degrees_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(motor_start_interpolation_60_degrees, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(17, 17, 17)
                .add(jSeparator6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(20, 20, 20)
                .add(jLabel6)
                .add(20, 20, 20)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_motor_max_current)
                    .add(LABEL_motor_max_current_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(motor_max_current, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_motor_max_regen_current)
                    .add(LABEL_motor_max_regen_current_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(motor_max_regen_current, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_pwm_duty_cycle_ramp_up_step)
                    .add(LABEL_pwm_duty_cycle_ramp_up_step_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(pwm_duty_cycle_ramp_up_step, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(LABEL_pwm_duty_cycle_ramp_down_step)
                    .add(LABEL_pwm_duty_cycle_ramp_down_step_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(6, 6, 6)
                .add(pwm_duty_cycle_ramp_down_step, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(jSeparator7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(45, 45, 45)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(ButtonWriteOptionBytes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(32, 32, 32)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(ButtonWriteConfiguration_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(ButtonWriteConfiguration, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(ButtonWriteOptionBytes_HELP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE)
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void throttle_typeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_throttle_typeActionPerformed
       if ("throttle and/or PAS".equals(throttle_type.getSelectedItem())){
            LABEL_throttle_control_algorithm_output.setVisible(true);
            throttle_control_algorithm_output.setVisible(true);
            LABEL_pas_number_of_magnets.setVisible(true);
            pas_number_of_magnets.setVisible(true);
            LABEL_pedal_max_cadence_in_rpm.setVisible(true);
            pedal_max_cadence_in_rpm.setVisible(true);
            LABEL_pas_rotation_direction.setVisible(true);
            pas_rotation_direction.setVisible(true);
            LABEL_throttle_control_algorithm_output_HELP.setVisible(true);
            LABEL_pas_number_of_magnets_HELP.setVisible(true);
            LABEL_pas_rotation_direction_HELP.setVisible(true);
            LABEL_pedal_max_cadence_in_rpm_HELP.setVisible(true);
   
            LABEL_torque_sensor_control_algorithm_output.setVisible(false);
            torque_sensor_control_algorithm_output.setVisible(false);       
            LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(false);
       } else if ("torque sensor".equals(throttle_type.getSelectedItem())) {
            LABEL_torque_sensor_control_algorithm_output.setVisible(true);
            torque_sensor_control_algorithm_output.setVisible(true);   
            LABEL_torque_sensor_control_algorithm_output_HELP.setVisible(true);
           
            LABEL_throttle_control_algorithm_output.setVisible(false);
            throttle_control_algorithm_output.setVisible(false);
            LABEL_pas_number_of_magnets.setVisible(false);
            pas_number_of_magnets.setVisible(false);
            LABEL_pedal_max_cadence_in_rpm.setVisible(false);
            pedal_max_cadence_in_rpm.setVisible(false);
            LABEL_pas_rotation_direction.setVisible(false);
            pas_rotation_direction.setVisible(false);
            LABEL_throttle_control_algorithm_output_HELP.setVisible(false);
            LABEL_pas_number_of_magnets_HELP.setVisible(false);
            LABEL_pas_rotation_direction_HELP.setVisible(false);
            LABEL_pedal_max_cadence_in_rpm_HELP.setVisible(false);
       }
    }//GEN-LAST:event_throttle_typeActionPerformed

    private void throttle_control_algorithm_outputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_throttle_control_algorithm_outputActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_throttle_control_algorithm_outputActionPerformed

    private void torque_sensor_control_algorithm_outputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_torque_sensor_control_algorithm_outputActionPerformed
        if ("direct torque value".equals(torque_sensor_control_algorithm_output.getSelectedItem())){
            LABEL_pas_number_of_magnets.setVisible(false);
            pas_number_of_magnets.setVisible(false);
            LABEL_pedal_max_cadence_in_rpm.setVisible(false);
            pedal_max_cadence_in_rpm.setVisible(false);
            LABEL_pas_rotation_direction.setVisible(false);
            pas_rotation_direction.setVisible(false);
            LABEL_pas_number_of_magnets_HELP.setVisible(false);
            LABEL_pas_rotation_direction_HELP.setVisible(false);
            LABEL_pedal_max_cadence_in_rpm_HELP.setVisible(false);
       } else {
            LABEL_pas_number_of_magnets.setVisible(true);
            pas_number_of_magnets.setVisible(true);
            LABEL_pedal_max_cadence_in_rpm.setVisible(true);
            pedal_max_cadence_in_rpm.setVisible(true);
            LABEL_pas_rotation_direction.setVisible(true);
            pas_rotation_direction.setVisible(true);
            LABEL_pas_number_of_magnets_HELP.setVisible(true);
            LABEL_pas_rotation_direction_HELP.setVisible(true);
            LABEL_pedal_max_cadence_in_rpm_HELP.setVisible(true);
       }
    }//GEN-LAST:event_torque_sensor_control_algorithm_outputActionPerformed

    private void pas_number_of_magnetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pas_number_of_magnetsActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pas_number_of_magnetsActionPerformed

    private void pedal_max_cadence_in_rpmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pedal_max_cadence_in_rpmActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pedal_max_cadence_in_rpmActionPerformed

    private void pas_rotation_directionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pas_rotation_directionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pas_rotation_directionActionPerformed

    private void LCD_assist_level_0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LCD_assist_level_0ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LCD_assist_level_0ActionPerformed

    private void LCD_assist_level_1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LCD_assist_level_1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LCD_assist_level_1ActionPerformed

    private void LCD_assist_level_2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LCD_assist_level_2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LCD_assist_level_2ActionPerformed

    private void LCD_assist_level_3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LCD_assist_level_3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LCD_assist_level_3ActionPerformed

    private void LCD_assist_level_4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LCD_assist_level_4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LCD_assist_level_4ActionPerformed

    private void LCD_assist_level_5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LCD_assist_level_5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LCD_assist_level_5ActionPerformed

    private void motor_rotor_offset_angleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_motor_rotor_offset_angleActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_motor_rotor_offset_angleActionPerformed

    private void foc_read_id_current_angle_adjustActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_foc_read_id_current_angle_adjustActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_foc_read_id_current_angle_adjustActionPerformed

    private void motor_start_interpolation_60_degreesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_motor_start_interpolation_60_degreesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_motor_start_interpolation_60_degreesActionPerformed

    private void motor_max_currentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_motor_max_currentActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_motor_max_currentActionPerformed

    private void motor_max_regen_currentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_motor_max_regen_currentActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_motor_max_regen_currentActionPerformed

    private void pwm_duty_cycle_ramp_up_stepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pwm_duty_cycle_ramp_up_stepActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pwm_duty_cycle_ramp_up_stepActionPerformed

    private void pwm_duty_cycle_ramp_down_stepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pwm_duty_cycle_ramp_down_stepActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pwm_duty_cycle_ramp_down_stepActionPerformed

    private void ButtonWriteOptionBytesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonWriteOptionBytesActionPerformed
        int n = JOptionPane.showConfirmDialog(
                null,
                "If you run this function with a brand new controller, the original firmware will be erased. This can't be undone. Are you sure?" ,
                "",
                JOptionPane.YES_NO_OPTION);

        if(n == JOptionPane.YES_OPTION)
        {
            try {
                if (OS.isWindows()) {
                    Runtime.getRuntime().exec("cmd /c start configuration_tool\\windows_scripts\\WriteOptionBytes");
                }
                else if (OS.isUnix()) {
                Process process = Runtime.getRuntime().exec("sh configuration_tool/linux_scripts/write_option_bytes.sh");
                    
                try {
                    process.waitFor();
                } catch (InterruptedException ex) {
                    Logger.getLogger(Configuration_tool.class.getName()).log(Level.SEVERE, null, ex);
                }
                
//                // for debug: next code will output the feedback and exit number of the process
//                StringBuffer output = new StringBuffer();
//                BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//                String line = "";                       
//                while ((line = reader.readLine())!= null) {
//                        output.append(line + "\n");
//                }
//                System.out.println("### " + output);
//                System.out.println ("exit: " + process.exitValue());
                
                process.destroy();
                }
            } catch (IOException e1) {
                showMessageDialog(null, "ERROR: ButtonWriteOptionBytes");
                e1.printStackTrace();
            }
        }
        else
        {
            // don't show nothing to user
        }
    }//GEN-LAST:event_ButtonWriteOptionBytesActionPerformed

    private void ButtonWriteConfigurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonWriteConfigurationActionPerformed
        PrintWriter pWriter = null; 
        try {
            if (OS.isWindows()) {
                pWriter = new PrintWriter(new BufferedWriter(new FileWriter("firmware\\config.h"))); // on Windows, slashs are different from Linux
            }
            else if (OS.isUnix()) {
                pWriter = new PrintWriter(new BufferedWriter(new FileWriter("firmware/config.h")));
            }
            pWriter.println("/*\r\n" + 
                        " * config.h\r\n" + 
                        " *\r\n" + 
                        " *  Automatically created by Flexible OpenSource firmware - Configuration tool\r\n" + 
                        " *  Author: stancecoke\r\n" +
                        " *  Author: casainho\r\n" + 
                        " */\r\n" + 
                        "\r\n" + 
                        "#ifndef CONFIG_H_\r\n" + 
                        "#define CONFIG_H_\r\n"); 
            
            String TextToSave = null;
                    
            if (throttle_type.getSelectedItem().equals("throttle and/or PAS")) {
                TextToSave = "#define EBIKE_THROTTLE_TYPE EBIKE_THROTTLE_TYPE_THROTTLE_PAS";
            }
            else {
                TextToSave = "#define EBIKE_THROTTLE_TYPE EBIKE_THROTTLE_TYPE_TORQUE_SENSOR";
            }            
            pWriter.println(TextToSave);
            
            if (throttle_control_algorithm_output.getSelectedItem().equals("direct PWM duty-cycle")) {
                TextToSave = "#define EBIKE_THROTTLE_TYPE_THROTTLE_PAS_PWM_DUTY_CYCLE";
            }
            else {
                TextToSave = "#define EBIKE_THROTTLE_TYPE_THROTTLE_PAS_CURRENT_SPEED";
            }            
            pWriter.println(TextToSave);

            if (torque_sensor_control_algorithm_output.getSelectedItem().equals("direct torque value")) {
            }
            else {
                TextToSave = "#define EBIKE_THROTTLE_TYPE_TORQUE_SENSOR_HUMAN_POWER";
                pWriter.println(TextToSave);
            }            

            TextToSave = "#define PAS_NUMBER_MAGNETS " + pas_number_of_magnets.getText();
            pWriter.println(TextToSave);

            TextToSave = "#define PAS_MAX_CADENCE_RPM " + pedal_max_cadence_in_rpm.getText();
            pWriter.println(TextToSave);  
            
            if (pas_rotation_direction.getSelectedItem().equals("left")) {
                TextToSave = "#define PAS_DIRECTION PAS_DIRECTION_LEFT";
            }
            else {
                TextToSave = "#define PAS_DIRECTION PAS_DIRECTION_RIGHT";
            }            
            pWriter.println(TextToSave);
            
            TextToSave = "#define ASSIST_LEVEL_0 " + LCD_assist_level_0.getText();
            pWriter.println(TextToSave);

            TextToSave = "#define ASSIST_LEVEL_1 " + LCD_assist_level_1.getText();
            pWriter.println(TextToSave);            
            
            TextToSave = "#define ASSIST_LEVEL_2 " + LCD_assist_level_2.getText();
            pWriter.println(TextToSave);
            
            TextToSave = "#define ASSIST_LEVEL_3 " + LCD_assist_level_3.getText();
            pWriter.println(TextToSave);

            TextToSave = "#define ASSIST_LEVEL_4 " + LCD_assist_level_4.getText();
            pWriter.println(TextToSave);            
            
            TextToSave = "#define ASSIST_LEVEL_5 " + LCD_assist_level_5.getText();
            pWriter.println(TextToSave);
            
            TextToSave = "#define BATTERY_LI_ION_CELLS_NUMBER " + lion_cells_number.getText();;
            pWriter.println(TextToSave);
            
            TextToSave = "#define MOTOR_ROTOR_OFFSET_ANGLE " + motor_rotor_offset_angle.getText();
            pWriter.println(TextToSave);
            
            TextToSave = "#define FOC_READ_ID_CURRENT_ANGLE_ADJUST " + foc_read_id_current_angle_adjust.getText();
            pWriter.println(TextToSave);
            
            TextToSave = "#define MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES " + motor_start_interpolation_60_degrees.getText();
            pWriter.println(TextToSave);                     

            TextToSave = "#define ADC_MOTOR_CURRENT_MAX " + String.valueOf(Integer.valueOf(motor_max_current.getText()) * 2);
            pWriter.println(TextToSave);                    
            
            TextToSave = "#define ADC_MOTOR_REGEN_CURRENT_MAX " + String.valueOf(Integer.valueOf(motor_max_regen_current.getText()) * 2);
            pWriter.println(TextToSave);
            
            TextToSave = "#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP " + pwm_duty_cycle_ramp_up_step.getText();
            pWriter.println(TextToSave);
            
            TextToSave = "#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP " + pwm_duty_cycle_ramp_down_step.getText();
            pWriter.println(TextToSave);

            pWriter.println("\r\n#endif /* CONFIG_H_ */"); 

        } catch (IOException ioe) { 
            ioe.printStackTrace(); 
        } finally {
            if (pWriter != null) { 
                pWriter.flush(); 
                pWriter.close(); 
            } 
        }
        
        try {
            if (OS.isWindows()) {
                Process process = Runtime.getRuntime().exec("cmd /c start configuration_tool\\windows_scripts\\Start_Compiling");
            }
            else if (OS.isUnix()) {
                Process process = Runtime.getRuntime().exec("sh configuration_tool/linux_scripts/build_and_flash.sh");
                try {
                    process.waitFor();
                } catch (InterruptedException ex) {
                    Logger.getLogger(Configuration_tool.class.getName()).log(Level.SEVERE, null, ex);
                }
                
//                // for debug: next code will output the feedback and exit number of the process
//                StringBuffer output = new StringBuffer();
//                BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//                String line = "";                       
//                while ((line = reader.readLine())!= null) {
//                        output.append(line + "\n");
//                }
//                System.out.println("### " + output);
//                System.out.println ("exit: " + process.exitValue());

                process.destroy();
            }
        } catch (IOException e1) {
            showMessageDialog(null, "ERROR: ButtonWriteConfiguration");
            e1.printStackTrace();
        }
    }//GEN-LAST:event_ButtonWriteConfigurationActionPerformed

    private void LABEL_throttle_type_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_throttle_type_HELPMouseClicked
        showMessageDialog(null, "You can use as throttle type a throttle and/or a PAS OR a torque sensor.\n\nIf you choose throttle and/or PAS, both will work simultaneous, otherwise you can connect and use only one of them.");
    }//GEN-LAST:event_LABEL_throttle_type_HELPMouseClicked

    private void LABEL_throttle_control_algorithm_output_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_throttle_control_algorithm_output_HELPMouseClicked
        showMessageDialog(null, "<html><b>direct PWM duty-cycle:</b> throttle control algorithm output value will be mapped directly to PWM duty-cycle<br><br><b>motor current and/or speed:</b> throttle control algorithm output value will define the motor torque/current and/or motor speed</html>");
    }//GEN-LAST:event_LABEL_throttle_control_algorithm_output_HELPMouseClicked

    private void LABEL_torque_sensor_control_algorithm_output_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_torque_sensor_control_algorithm_output_HELPMouseClicked
        showMessageDialog(null, "<html><b>direct torque:</b> the torque signal from the torque sensor will be used and the PAS signal from the torque sensor will be ignored.<br>The motor will start when user apply force to the pedals, even wihout any pedalling.<br><br><b>human power:</b> both torque signal and the PAS signal from the torque sensor will be used (torque * candence).<br> The motor will start only when user rotate and apply force to the pedals.</html>");
    }//GEN-LAST:event_LABEL_torque_sensor_control_algorithm_output_HELPMouseClicked

    private void LABEL_pas_number_of_magnets_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_pas_number_of_magnets_HELPMouseClicked
        showMessageDialog(null, "Number of magnets on the PAS disk. BMSBATTERY bottom bracket torque sensor has 12 magnets.");
    }//GEN-LAST:event_LABEL_pas_number_of_magnets_HELPMouseClicked

    private void LABEL_pas_rotation_direction_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_pas_rotation_direction_HELPMouseClicked
        showMessageDialog(null, "When using PAS, the motor should start only when rotating the pedals forward. If instead the motor\n starts when rotating pedals backwards, invert the PAS rotation direction value.");
    }//GEN-LAST:event_LABEL_pas_rotation_direction_HELPMouseClicked

    private void LABEL_pedal_max_cadence_in_rpm_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_pedal_max_cadence_in_rpm_HELPMouseClicked
        showMessageDialog(null, "Max value for pedal cadence (in RPM).\nThe throttle control algorithm, when using the pedals cadence value, will scale his output value by a factor of the pedal cadence.");
    }//GEN-LAST:event_LABEL_pedal_max_cadence_in_rpm_HELPMouseClicked

    private void LABEL_LCD_assist_level_0_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_LCD_assist_level_0_HELPMouseClicked
        showMessageDialog(null, "The throttle algorithm output value will be scaled by the factor value of LCD assist level.\nChoose a scale factor for the corresponding LCD assist level.");
    }//GEN-LAST:event_LABEL_LCD_assist_level_0_HELPMouseClicked

    private void LABEL_motor_rotor_offset_angle_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_motor_rotor_offset_angle_HELPMouseClicked
        showMessageDialog(null, "This value must be found experimenting. Motor should rotate forward and have a good torque, a\n value to much higher or lower will make the motor not having torque while the motor starting up.\nThis value can be tested with motor blocked, at startup, to found a value where is does have the best torque at startup.\nA value of 202 was found to be a good one for BMSBattery Q85 motor with S06S controller.");
    }//GEN-LAST:event_LABEL_motor_rotor_offset_angle_HELPMouseClicked

    private void LABEL_foc_read_id_current_angle_adjust_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_foc_read_id_current_angle_adjust_HELPMouseClicked
        showMessageDialog(null, "This value at 127 is the default but a value a bit higher or lower my improve the controller efficiency\n" +
"This value can be tested with motor running at medium speed, where it is already running with sinewave interpolation (not at startup)\n" +
"A way to test: put the motor with the same mechanical load (like on a bike training roller) and with a constant speed\n" +
"changing this value will make the motor to need more or less current to mantain the same speed -- adjust to use the least current possible\n" +
"A value of FOC_READ_ID_CURRENT_ANGLE_ADJUST = 137 was found to be a good one for BMSBattery Q85 motor with S06S controller");
    }//GEN-LAST:event_LABEL_foc_read_id_current_angle_adjust_HELPMouseClicked

    private void LABEL_motor_start_interpolation_60_degrees_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_motor_start_interpolation_60_degrees_HELPMouseClicked
        showMessageDialog(null, "This value is ERPS speed after which a transition happens from sinewave no interpolation to have interpolation 60 degrees\n and must be found experimentally but a value of 40 may be good");
    }//GEN-LAST:event_LABEL_motor_start_interpolation_60_degrees_HELPMouseClicked

    private void LABEL_pwm_duty_cycle_ramp_up_step_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_pwm_duty_cycle_ramp_up_step_HELPMouseClicked
        showMessageDialog(null, "Higher value mean a slower ramp up of PWM duty-cycle value");
    }//GEN-LAST:event_LABEL_pwm_duty_cycle_ramp_up_step_HELPMouseClicked

    private void LABEL_motor_max_current_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_motor_max_current_HELPMouseClicked
        showMessageDialog(null, "Motor controller max current");
    }//GEN-LAST:event_LABEL_motor_max_current_HELPMouseClicked

    private void LABEL_motor_max_regen_current_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_motor_max_regen_current_HELPMouseClicked
        showMessageDialog(null, "Motor controller max regeneration/ebrake current.\nThis value depends on how much your batteries can withstand.\nThe controller can't handle more than motor max current value");
    }//GEN-LAST:event_LABEL_motor_max_regen_current_HELPMouseClicked

    private void LABEL_pwm_duty_cycle_ramp_down_step_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_pwm_duty_cycle_ramp_down_step_HELPMouseClicked
        showMessageDialog(null, "Higher value mean a slower ramp down of PWM duty-cycle value");
    }//GEN-LAST:event_LABEL_pwm_duty_cycle_ramp_down_step_HELPMouseClicked

    private void ButtonWriteConfiguration_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonWriteConfiguration_HELPMouseClicked
        showMessageDialog(null, "Builds and flash the firmware, using the chosen options.");
    }//GEN-LAST:event_ButtonWriteConfiguration_HELPMouseClicked

    private void ButtonWriteOptionBytes_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ButtonWriteOptionBytes_HELPMouseClicked
        showMessageDialog(null, "Erase the microcontroller original firmware and configure the microcontroller option bytes.\nThis need to be done only once, to erase the original firmware fo the motor controller.");
    }//GEN-LAST:event_ButtonWriteOptionBytes_HELPMouseClicked

    private void lion_cells_numberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lion_cells_numberActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_lion_cells_numberActionPerformed

    private void LABEL_lion_cells_number_HELPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LABEL_lion_cells_number_HELPMouseClicked
        showMessageDialog(null, "Please choose a number of Lion cells that your battery pack has. For instance, choose 7 for 24V battery pack.\nPlease note that you should use a battery pack voltage that your controller can handle, other way it will probably fail to work correctly.");
    }//GEN-LAST:event_LABEL_lion_cells_number_HELPMouseClicked
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) throws ClassNotFoundException, InstantiationException {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
            * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
            */
//        try {
//            javax.swing.UIManager.LookAndFeelInfo[] installedLookAndFeels=javax.swing.UIManager.getInstalledLookAndFeels();
//            for (int idx=0; idx<installedLookAndFeels.length; idx++)
//                if ("Nimbus".equals(installedLookAndFeels[idx].getName())) {
//                    javax.swing.UIManager.setLookAndFeel(installedLookAndFeels[idx].getClassName());
//                    break;
//                }
//            
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(Configuration_tool.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(Configuration_tool.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(Configuration_tool.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(Configuration_tool.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//</editor-fold>
//</editor-fold>

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Configuration_tool.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Configuration_tool.class.getName()).log(Level.SEVERE, null, ex);
        }

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Configuration_tool().setVisible(true);
            }
        });
    }
    
    public class OSValidator {

        private String OS = System.getProperty("os.name").toLowerCase();

        public boolean isWindows() {
            return (OS.indexOf("win") >= 0);
        }

        public boolean isMac() {
            return (OS.indexOf("mac") >= 0);
        }

        public boolean isUnix() {
            return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 );
        }

        public boolean isSolaris() {
            return (OS.indexOf("sunos") >= 0);
        }
        
        public String getOS(){
            if (isWindows()) {
                return "win";
            } else if (isMac()) {
                return "osx";
            } else if (isUnix()) {
                return "uni";
            } else if (isSolaris()) {
                return "sol";
            } else {
                return "err";
            }
        }
    }
    
    private OSValidator OS = new OSValidator ();
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ButtonWriteConfiguration;
    private javax.swing.JLabel ButtonWriteConfiguration_HELP;
    private javax.swing.JButton ButtonWriteOptionBytes;
    private javax.swing.JLabel ButtonWriteOptionBytes_HELP;
    private javax.swing.JLabel LABEL_LCD_assist_level_0;
    private javax.swing.JLabel LABEL_LCD_assist_level_0_HELP;
    private javax.swing.JLabel LABEL_LCD_assist_level_1;
    private javax.swing.JLabel LABEL_LCD_assist_level_2;
    private javax.swing.JLabel LABEL_LCD_assist_level_3;
    private javax.swing.JLabel LABEL_LCD_assist_level_4;
    private javax.swing.JLabel LABEL_LCD_assist_level_5;
    private javax.swing.JLabel LABEL_foc_read_id_current_angle_adjust;
    private javax.swing.JLabel LABEL_foc_read_id_current_angle_adjust_HELP;
    private javax.swing.JLabel LABEL_lion_cells_number;
    private javax.swing.JLabel LABEL_lion_cells_number_HELP;
    private javax.swing.JLabel LABEL_motor_max_current;
    private javax.swing.JLabel LABEL_motor_max_current_HELP;
    private javax.swing.JLabel LABEL_motor_max_regen_current;
    private javax.swing.JLabel LABEL_motor_max_regen_current_HELP;
    private javax.swing.JLabel LABEL_motor_rotor_offset_angle;
    private javax.swing.JLabel LABEL_motor_rotor_offset_angle_HELP;
    private javax.swing.JLabel LABEL_motor_start_interpolation_60_degrees;
    private javax.swing.JLabel LABEL_motor_start_interpolation_60_degrees_HELP;
    private javax.swing.JLabel LABEL_pas_number_of_magnets;
    private javax.swing.JLabel LABEL_pas_number_of_magnets_HELP;
    private javax.swing.JLabel LABEL_pas_rotation_direction;
    private javax.swing.JLabel LABEL_pas_rotation_direction_HELP;
    private javax.swing.JLabel LABEL_pedal_max_cadence_in_rpm;
    private javax.swing.JLabel LABEL_pedal_max_cadence_in_rpm_HELP;
    private javax.swing.JLabel LABEL_pwm_duty_cycle_ramp_down_step;
    private javax.swing.JLabel LABEL_pwm_duty_cycle_ramp_down_step_HELP;
    private javax.swing.JLabel LABEL_pwm_duty_cycle_ramp_up_step;
    private javax.swing.JLabel LABEL_pwm_duty_cycle_ramp_up_step_HELP;
    private javax.swing.JLabel LABEL_throttle_control_algorithm_output;
    private javax.swing.JLabel LABEL_throttle_control_algorithm_output_HELP;
    private javax.swing.JLabel LABEL_throttle_type;
    private javax.swing.JLabel LABEL_throttle_type_HELP;
    private javax.swing.JLabel LABEL_torque_sensor_control_algorithm_output;
    private javax.swing.JLabel LABEL_torque_sensor_control_algorithm_output_HELP;
    private javax.swing.JTextField LCD_assist_level_0;
    private javax.swing.JTextField LCD_assist_level_1;
    private javax.swing.JTextField LCD_assist_level_2;
    private javax.swing.JTextField LCD_assist_level_3;
    private javax.swing.JTextField LCD_assist_level_4;
    private javax.swing.JTextField LCD_assist_level_5;
    private javax.swing.JTextField foc_read_id_current_angle_adjust;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JTextField lion_cells_number;
    private javax.swing.JTextField motor_max_current;
    private javax.swing.JTextField motor_max_regen_current;
    private javax.swing.JTextField motor_rotor_offset_angle;
    private javax.swing.JTextField motor_start_interpolation_60_degrees;
    private javax.swing.JTextField pas_number_of_magnets;
    private javax.swing.JComboBox<String> pas_rotation_direction;
    private javax.swing.JTextField pedal_max_cadence_in_rpm;
    private javax.swing.JTextField pwm_duty_cycle_ramp_down_step;
    private javax.swing.JTextField pwm_duty_cycle_ramp_up_step;
    private javax.swing.JComboBox<String> throttle_control_algorithm_output;
    private javax.swing.JComboBox<String> throttle_type;
    private javax.swing.JComboBox<String> torque_sensor_control_algorithm_output;
    // End of variables declaration//GEN-END:variables
    
}
